import { Space, Image, Tag, Button, Pagination } from 'antd';
import { useEffect, useState } from 'react';
import { useSearchParams } from 'react-router-dom';
import{newDeatil}from "../../api/school"
const SchoolDetail: React.FC = (): JSX.Element => {
    const[query]=useSearchParams()
    const[id,setid]=useState(query.get('id'))
    // console.log(id);
    const[newInfo,setnew]:any=useState([])
    const getNewDeatil=async()=>{
        let res:any=await newDeatil({id})
        // console.log(res);
        if(res.code==='00000'){
            setnew(res.data)
        }
        
    }
    useEffect(()=>{
        getNewDeatil()
    },[id])
    return (<>
        <h3>详情</h3>
        <div className="schoolDetail">
            <div className="item">
                <div>标题:</div>
                <div>{newInfo.title}</div>
            </div>
            <div className="item">
                <div>作者:</div>
                <div>{newInfo.author}</div>
            </div>
            <div className="item">
                <div>关键字:</div>
                <div>{newInfo.keywords}</div>
            </div>
            <div className="item">
                <div>介绍:</div>
                <div>{newInfo.desc}</div>
            </div>
            <div className="item">
                <div>正文:</div>
                {/* 渲染html标签  dangerouslySetInnerHTML*/}
                <div dangerouslySetInnerHTML={{__html:newInfo.content}}/>
            </div>
            <div className="item">
                <div>新闻添加时间:</div>
                <div>{newInfo.add_time}</div>
            </div>
            <div className="item">
        <div>新闻图片</div>
        <div>
          <Image
            width={100}
            height={100}
            preview={false}
            src="error"
            alt='加载失败'
            // placeholder='j、iazaishib'
            fallback={newInfo.thumb}
          />
        </div>
      </div>
        </div>
    </>)
}
export default SchoolDetail